//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
//#include "ctype.h"
#include "system.h"

typedef int size_t;

#if 0
/************************************************************************/
/* tffscpy - copy one memory block to the other.                        */
/************************************************************************/
/*void memcpy(void *dest, void *src, unsigned length)
{
  while( length-- )
    *(((char *)dest)++) = *(((char *)src)++);
}
*/

void *memcpy(void *dest,const void *src,size_t count)
{
	char *tmp = (char *)dest,*s=(char *)src;
	while(count--)
		*tmp++=*s++;
	return dest;
}

/************************************************************************/
/* tffscmp - compare two memory blocks.                                 */
/************************************************************************/
/*int memcmp(void *src1, void *src2, unsigned length)
{
  while( length-- )
    if (*(((char *)src1)++) != *(((char *)src2)++))
      return(1);
  return(0);
}
*/
int memcmp(const void *cs,const void *ct,size_t count)
{
	const unsigned char *su1,*su2;
	int res = 0 ;
	for(su1 =cs,su2 =ct;0<count;++su1,++su2,count--)
		if((res = *su1-*su2)!=0)
			break;
	return res;
}


/************************************************************************/
/* tffsset - set a memory blocks to a certain value.                    */
/************************************************************************/
/*void memset(void *dest, unsigned char value, unsigned length)
{
  while( length-- )
    *(((char *)dest)++) = value;
}
*/

void *memset(void *s,int c,size_t count)
{
	char *xs = (char*)s;
	while(count--)
		*xs++=c;
	return s;
}
#endif



void *flmemcpy(void * dest,const void *src,size_t count)
{
	        size_t i;
		        unsigned char *ldest = (unsigned char *)dest;
			        const unsigned char *lsrc = (unsigned char *)src;

				        for(i=0;( i < count );i++,ldest++,lsrc++)
						                *(ldest) = *(lsrc);
					        return dest;
}

void *flmemset(void * dest,int c,size_t count)
{
	        size_t i;
		        unsigned char *ldest = (unsigned char *)dest;

			        for(i=0;( i < count );i++,ldest++)
					                *(ldest) = (unsigned char)c;
				        return dest;
}

int flmemcmp(const void * dest,const void *src,size_t count)
{
	        size_t i;
		        const unsigned char *ldest = (unsigned char *)dest;
			        const unsigned char *lsrc = (unsigned char *)src;

				        for(i=0;( i < count );i++,ldest++,lsrc++)
						                if( *(ldest) != *(lsrc) )
									                return (*(ldest)-*(lsrc));
					        return 0;
}

